import { downloadFileFromBlobPart } from '@vben/utils'

import { requestClient } from '#/api/request'

/**
 * 获取采购退料列表
 */
export async function getRefundRecordList(params: any) {
  return requestClient.get('/admin/RefundRecord/index', params)
}

/**
 * 获取采购退料详情
 */
export async function getRefundRecordDetailEditInfo(params: any) {
  return requestClient.get('/admin/RefundRecord/edit', params)
}

/**
 * 新增采购退料
 */
export async function doRefundRecordAdd(params: any) {
  return requestClient.post('/admin/RefundRecord/add', params)
}

/**
 * 编辑采购退料
 */
export async function doRefundRecordEdit(params: any) {
  return requestClient.post('/admin/RefundRecord/edit', params)
}

/**
 * 删除采购退料
 */
export async function doRefundRecordDelete(params: any) {
  return requestClient.post('/admin/RefundRecord/del', params)
}

/**
 * 审核采购退料
 */
export async function doRefundRecordApproval(params: any) {
  return requestClient.post('/admin/RefundRecord/approval', params)
}

/**
 * 反审采购退料
 */
export async function doRefundRecordAgainst(params: any) {
  return requestClient.post('/admin/RefundRecord/against', params)
}

/**
 * 导出采购退料数据
 */
export async function exportRefundData(params: any) {
  const res = await requestClient.post('/admin/RefundRecord/export', params, {
    responseType: 'blob',
  })
  
  if (res.data) {
    downloadFileFromBlobPart(res.data, '采购退料数据.xlsx')
  }
  
  return res
} 